export default function (res) {
    const { body } = res;

    const reqBodySchema = JSON.parse(
        '{"description":"员工离岗参数","type":"object","required":["endDate","recordId","userId"],"properties":{"userId":{"type":"integer","description":"员工ID","format":"int64"},"recordId":{"type":"integer","description":"岗位记录ID","format":"int64"},"endDate":{"type":"string","description":"离岗日期","format":"date"}}}'
    );

    // 校验必填参数
    if (reqBodySchema.required && reqBodySchema.required.length > 0) {
        for (const requiredField of reqBodySchema.required) {
            if (!body || !Object.prototype.hasOwnProperty.call(body, requiredField)) {
                return new Promise((resolve) => {
                    resolve({
                        code: 1,
                        message: `缺少必填参数：${requiredField}`,
                    });
                });
            }
        }
    }

    // 如果所有必填参数都存在，则生成 Mock 数据
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve({
                code: 0,
                message: 'success',
                data: {}, // 业务数据是空对象，表示离岗操作成功
                timestamp: Date.now(),
                requestId: 'requestId' + Math.floor(Math.random() * 1000),
                signature: 'signature' + Math.floor(Math.random() * 1000),
            });
        }, 100);
    });
}